import time

from selenium.webdriver.common.by import By

from Base.page_base import PageBase


class PageLogin(PageBase):
    def __init__(self, driver):
        super().__init__(driver)
        # 点击我的
        self.__me = (By.ID,'com.tpshop.malls:id/mine_img')
        # 点击登录/注册
        self.__login = (By.ID,'com.tpshop.malls:id/head_img')
        #输入手机号
        self.__phone = (By.ID,'com.tpshop.malls:id/mobile_et')
        #输入密码
        self.__pwd = (By.ID,'com.tpshop.malls:id/pwd_et')
        #勾选协议
        self.__check = (By.ID,'com.tpshop.malls:id/agree_btn')
        #点击登录按钮
        self.__login_btn = (By.ID,'com.tpshop.malls:id/login_tv')
        #登录成功结果
        # self.login_result = (By.ID,'com.tpshop.malls:id/nick_name_tv')
        # #登录失败结果
        # self.login_fail = (By.ID,'com.tpshop.malls:id/title_tv')
        #获取toast
        self.__toast_result=(By.XPATH,'//android.widget.Toast')

    def login_input(self,phone,pwd):
        time.sleep(4)
        self.base_click(self.__me)
        time.sleep(5)
        self.base_click(self.__login)
        self.base_input(self.__phone,phone)
        self.base_input(self.__pwd,pwd)
        self.base_click(self.__check)
        self.base_click(self.__login_btn)
    # def get_login_success(self):
    #     time.sleep(2)
    #     result = self.fd_element(self.login_result).text
    #     return result
    def get_toast_result(self):
        return self.fd_element(self.__toast_result).text
    # def get_login_fail(self):
    #     time.sleep(2)
    #     result01 = self.fd_element(self.__login_fail).text
    #     return result01
    #
